package com.parkcar;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import HttpUtils.HttpInfoRequest;
import util.BaseActivity;
import util.BaseTools;
import util.Constrants;

/**
 * Created by Administrator on 2016/2/23.
 */
public class NameChangeActivity extends BaseActivity{
    private EditText nickname;
    private HttpInfoRequest infoRequest;
    @Override
    protected void setUpui(Bundle arg0) {
        setContentView(R.layout.activity_name_change);
        setTopName("昵称修改","");
        nickname = (EditText) findViewById(R.id.nickname);
        if(BaseTools.isValueEmpty(Constrants.mInfo.getNickName())){
            nickname.setText(Constrants.mInfo.getNickName());
        }
    }

    @Override
    protected void updateUI(boolean isLogin) {

    }
    public void submit(View view){
        String name = nickname.getText().toString();
        if(!BaseTools.isValueEmpty(name)){
            infoRequest = new HttpInfoRequest(this,3);
            infoRequest.setmIHttpClinetListener(this);
            infoRequest.changeInfo(name,-1,"");
            infoRequest.doRequest();
        }
    }

    @Override
    public void httpSuccessListener(Bundle successMsg) {
        super.httpSuccessListener(successMsg);
        if(infoRequest!=null&&action.equalsIgnoreCase(infoRequest.getAction())){
            if(mBaseResult.getStatus().getRetCode()==0){
                Constrants.mInfo.setNickName(nickname.getText().toString());
                setResult(Constrants.CHANGE_NAME);
                finish();
            }toast(mBaseResult.getStatus().getMsg());

        }
    }
}
